package com.zhouyibike.uu.ui.activity;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.map.MapView;
import com.zhouyibike.uu.R;
import com.zhouyibike.uu.ui.base.BaseActivity;

public class TestActivity extends BaseActivity {
    TextView t1, t2, t3, t4, et;

    String key = "";
    private MapView mMapView = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        SDKInitializer.initialize(getApplicationContext());
        t1 = (TextView) findViewById(R.id.t1);
        t2 = (TextView) findViewById(R.id.t2);
        t3 = (TextView) findViewById(R.id.t3);
        t4 = (TextView) findViewById(R.id.t4);
        et = (EditText) findViewById(R.id.editHide);
        et.addTextChangedListener(tw);
        mMapView = (MapView) findViewById(R.id.bmapView);
    }
    void setKey() {
        char[] arr = key.toCharArray();
        t1.setText("");
        t2.setText("");
        t3.setText("");
        t4.setText("");
        for (int i = 0; i < arr.length; i++) {
            if (i == 0) {
                t1.setText(String.valueOf(arr[0]));
            } else if (i == 1) {
                t2.setText(String.valueOf(arr[1]));
            } else if (i == 2) {
                t3.setText(String.valueOf(arr[2]));
            } else if (i == 3) {
                t4.setText(String.valueOf(arr[3]));
            }
        }
    }

    TextWatcher tw = new TextWatcher() {
        @Override
        public void onTextChanged(CharSequence s, int start, int before,
                                  int count) {

        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                                      int after) {

        }

        @Override
        public void afterTextChanged(Editable s) {
            key = s.toString();
            setKey();
        }
    };
}
